package com.isorf.controller;

import com.isorf.service.AdminService;
import com.isorf.service.impl.AdminServiceImpl;
import com.isorf.util.ResponseResult;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Api(tags = "后台登录接口")
@RequestMapping("/admin")
@RestController
public class AdminController {
    @Autowired     //自动注入，根据类型把Spring创建的对象赋值给 adminService属性
    private AdminService adminService;
    @PostMapping("/login")
    public ResponseResult<Boolean> login(String username, String password){
        //Controller 层调业务逻辑层，业务层的返回值 是Boolean类型的
        Boolean result = adminService.login(username, password);
        if( result){
            return ResponseResult.success(ResponseResult.SUCCESS,"登录成功", result);
        }else{
            return ResponseResult.failure(ResponseResult.FAILED,"用户名或密码错误");
        }
    }
}
